<div class="form-inline">
    <div class="form-group">
        <label class="control-label">统计精度</label>
        <select name="accuracy" class="form-control">
            <option value="1" selected>按时</option>
            <option value="2">按日</option>
            <option value="3">按月</option>
        </select>
    </div>
    <div class="form-group">
        <label class="control-label">按商户</label>
        <input type="text" class="form-control" id="mchInfo" placeholder="商户登录名/商户编码" name="mch_info">
    </div>

        <div class="form-group">
            <label>日期范围</label>
            <div class="input-group">
                <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                </div>
                <input type="text" class="form-control" id="created_at_start" placeholder="起始时间" name="created_at[start]" value="{{\Carbon\Carbon::now()->startOfDay()->toDateTimeString()}}">
                <span class="input-group-addon" style="border-left: 0; border-right: 0;">-</span>
                <input type="text" class="form-control" id="created_at_end" placeholder="结束时间" name="created_at[end]" value="{{\Carbon\Carbon::now()->toDateTimeString()}}">
            </div>
        </div>


    <div class="form-group">
        <label class="radio-inline">
            <input type="radio" name="staticRange"  value="-1" checked> 按选择范围
        </label>
        <label class="radio-inline">
            <input type="radio" name="staticRange"  value="1"> 本周
        </label>
        <label class="radio-inline">
            <input type="radio" name="staticRange"  value="2"> 本月
        </label>
        <label class="radio-inline">
            <input type="radio" name="staticRange"  value="3"> 近三个月
        </label>
    </div>


    <button type="submit" class="btn btn-default">查询</button>
</div>

<script type="text/javascript">
    var postData;
    var defaultData = getPostData(
        1,
        '',
        '{{\Carbon\Carbon::now()->startOfDay()->toDateTimeString()}}',
        '{{\Carbon\Carbon::now()->toDateTimeString()}}',
        -1
    );

    $(function () {
        $('#created_at_start').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN"});
        $('#created_at_end').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN","useCurrent":false});
        $("#created_at_start").on("dp.change", function (e) {
            $('#created_at_end').data("DateTimePicker").minDate(e.date);
        });
        $("#created_at_end").on("dp.change", function (e) {
            $('#created_at_start').data("DateTimePicker").maxDate(e.date);
        });

        $("input[name='staticRange']").click(function () {
             if ($(this).val() == -1) {
                 $("#created_at_start").attr('readonly', false);
                 $("#created_at_end").attr('readonly', false);
             } else {
                 $("#created_at_start").attr('readonly', true);
                 $("#created_at_end").attr('readonly', true);
             }

        });

        $("button[type='submit']").on('click', function () {
            var accuracy = $("select[name='accuracy']").val();
            var mchInfo = $("input#mchInfo").val();
            var created_at_start = $("#created_at_start").val();
            var created_at_end = $("#created_at_end").val();
            var staticRange = $("input[name='staticRange']:checked").val();

            postData = getPostData(accuracy, mchInfo, created_at_start, created_at_end, staticRange);


            //财务收支明细api
            setFinanceLineOption(postData);
            //订单量结算api
            setOrderLineOption(postData);

            //通道成功率表格
            getPaymentsTable(postData);

            //接口商统计

        });


    });


    //自适应宽高
    var myChartContainer = function (chat) {
        chat.style.width = $(chat).parent('div').width()+'px';
        chat.style.height = $(chat).parent('div').height()+'px';
    };


    function getPostData(accuracy, mchInfo, created_at_start, created_at_end, staticRange) {
        return {
            'accuracy': accuracy,
            'mchInfo': mchInfo,
            'start_at': created_at_start,
            'end_at': created_at_end,
            'staticRange': staticRange
        };
    }
</script>
